import { Component } from '@angular/core';
import {BMIForm} from './vo/BMIForm';
import {ResultVo} from './vo/ResultVo';
import {BmiService} from './service/bmi.service';




@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  bmiform: BMIForm;
  resultvo: ResultVo;
  imgourl: string;

  constructor(private bmiservice: BmiService) {
    this.bmiform = new BMIForm();
    this.resultvo = new ResultVo();


  }

getBMivalue() {

    console.log('身高' + this.bmiform.sa + '体重' + this.bmiform.tz);
    this.bmiservice.getBMIValue(this.bmiform)
    .then((data: any) => {
      this.resultvo = data;
      this.getPic();
    });
}

getPic() {
    switch (this.resultvo.state) {
      case '偏瘦':
        this.imgourl = '/assets/images/thin.jpg';
        break;
      case '正常':
        this.imgourl = '/assets/images/normal.jpg';
        break;
      case '微胖':
        this.imgourl = '/assets/images/babyfat.jpg';
        break;
      case '肥胖':
        this.imgourl = '/assets/images/fat.jpg';
        break;

    }
}

}

